This file contains the online documentation for the different
CraftScript constructions displayed in the CraftScript Tool in the
Toolbox.

#begin
define_method_long
Syntax:
define method name(arg_1, arg_2)
	of {class_name}
	in category_1 category_2 
	with local local_1 local_2
	 global global_1 global_2
	 property prop_1 prop_2
	as 
	exprs
end define 

Comment:
A definition of the method name of the class class_name with the arguments arg_1 and arg_2. The method will be found in the categories category_1 and category_2.
In this method local_1 and local_2 will refer to local variables, global_1 and global_2 will refer to global variables and prop_1 and prop_2 will refer to properties of the class.

Examples:
This example defines a method in the math category of the class my_class. 
Note: Since x, y and z are arguments, they do not need to be declared as local variables like in the example.

define method my_add(x, y, z)
	of {my_class}
	in math 
	with local x y z
	as 
	return x + y + z
end define 
#end

#begin
define_method_short
Syntax:
define method name(arg_1)
	of {class_name}
	as 
	exprs
end define 

Comment:
A definition of the method name of the class class_name with the argument arg_1.

Examples:
This example defines a method for the class my_class. 

define method add_one(x)
	of {my_class}
	as 
	return x + 1
end define 
#end

#begin
define_class
Syntax:
define class method name(arg_1)
	of {class_name}
	as 
	exprs
end define 

Comment:
A definition of the class method name of the class class_name with the argument arg_1.

Examples:
This example defines a class method for the class my_class. 

define class method return_two
	of {my_class}
	as 
	x := self:new
	y := self:new
	return [x y]
end define 
#end

#begin
if_then
Syntax:
if expr then 
	exprs
end if

Comment:
If expr evaluates to a non-false value, the expressions in exprs are evaluated.
Returns the value of the last evaluated expression, i.e. if expr evaluates to false it returns false and if expr evaluates to true it returns the value of the last expr in exprs. 

Examples:
This example returns 10 if a is larger than 100 and false otherwise.

if a > 100 then
	print("------")
	print("a is large")
	print("------")
	10
end if
#end

#begin
if_then_else
Syntax:
if expr then 
	exprs_1
else 
	exprs_2
end if

Comment:
If expr evaluates to a non-false value, the expressions in exprs_1 are evaluated. Otherwise the expressions in exprs_2 are evaluated.
Returns the value of the last evaluated expression, i.e. if expr evaluates to false it returns the value of the last expression in exprs_2 and if expr evaluates to true it returns the value of the last expr in exprs_1.

Examples:
This example returns 10 if a is larger than 100 and 20 otherwise.

if a > 100 then 
	print("------")
	print("a is large")
	print("------")
	10
else 
	print("------")
	print("a is small")
	print("------")
	20
end if
#end

#begin
while
Syntax:
while expr do 
	exprs
end while

Comment:
As long as expr evaluates to a non-false value, the expressions in exprs will be evaluated.
Returns the value of the last evaluated expression, i.e. if expr evaluates to false the first time it returns false and else it returns the value of the last expr in exprs.

Examples:
If a is greater than 9 this example returns false and otherwise it returns the value of a := a + 1 the last time it evaluates, i.e. 10.

while a < 10 do 
	print("------")
	print(a)
	print("------")
	a := a + 1
end while
#end

#begin
until
Syntax:
until expr do 
	exprs
end until

Comment:
The expressions in exprs will be evaluated until expr evaluates to false.
Returns the value of the last evaluated expression in exprs.

Note: The expressions in exprs will be evaluated at least one time.

Examples:
This example always evaluates to the value of a + 1.

until a > 10 do 
	print("------")
	print(a)
	print("------")
	a := a + 1
end until
#end

#begin
case
Syntax:
case expr
	value_1 do 
		exprs_1
	end do 
	value_2 do 
		exprs_2
	end do 
	otherwise do 
		exprs_3
	end do 
end case 

Comment:
If expr evaluates to value_1 the expressions in exprs_1 will be evaluated, if expr evaluates to value_2 the expressions in exprs_2 will be evaluated etc.
a non-false value, the expressions in exprs will be evaluated.
If expr evaluates to another value the expressions in exprs_3 will be evaluated. 
Returns the value of the last evaluated expression, i.e. if expr evaluates to value_1 it returns the value of the last expr in exprs_1 etc.

Examples:
This example will return 10 if a is 1, 20 if a is 2 and 30 otherwise.

case a
	1 do 
		print("a is one")
		10
	end do 
	2 do 
		print("a is two")
		20
	end do 
	otherwise do 
		print("a is something else")
		30
	end do 
end case 
#end

#begin
return 
Syntax:
return expr

Comment:
The return expression is used to make a method return a specific value. By default a method returns the value of the last expression in the method.
A return expression will stop the evaluation of the method and the method will return the value of the expression expr.

Examples:
This example is a method defined for the program. 
If the method is called with x less than or equal to 10 the method returns 10, otherwise the method returns x + 1.

define method foo(x)
	of the_program
	as 
	if x > 100 then
		return x + 1
	end if
	10
end define 

the_program:foo(2)
returns 10
the_program:foo(200)
returns 201
#end

#begin
exit_loop
Syntax:
exit_loop expr

Comment:
The exit_loop expression is used to break the current loop and to make the loop return a specific value. By default a loop returns the value of the last expression in the loop.
An exit_loop expression will stop the evaluation of the loop and the loop will return the value of the expression expr.

Note: Only the innermost loop will be exited.

Examples:
This example prints the numbers from 1 to 9. When x is 10 the loop will be exited and the return value of the loop will be "exit".

for x from 1 to 100 do
	if x = 10 then 
		exit_loop "exit"
	end if 
	print(x)
end for 
#end

#begin
next_loop
Syntax:
next_loop expr

Comment:
The next_loop expression is used to jump to the beginning of the loop without executing the expressions after the next_loop expression.
If the next_loop expression is executed in the last loop, the loop will return the value of the expression expr.

Examples:
This example prints the numbers from 1 to 10 except 5. When x is 5 the next_loop expression will jump to the start of the loop and the print expression will never execute.

for x from 1 to 10 do
	if x = 5 then 
		next_loop 0
	end if 
	print(x)
end for 
#end

#begin
comment_1
Syntax:
; comment

Comment:
If you begin a line with a semi-colon (;) the line will be treated as a comment and will not be executed.

Examples:
This example prints the numbers from 1 to 5. The print("hello") expression will never execute since it is a comment.

for x from 1 to 5 do
	; print("hello")
	print(x)
end for 
#end

#begin
comment_2
Syntax:
;; comment

Comment:
If you begin a line with two semi-colons (;;) the line will be treated as a comment and will not be executed. 

Note: Two semi-colons will tab-adjust the comment one position to the right.

Examples:
This example prints the numbers from 1 to 5. The print("hello") expression will never execute since it is a comment.

for x from 1 to 5 do
		;; print("hello")
	print(x)
end for 
#end

#begin
comment_3
Syntax:
;;; comment

Comment:
If you begin a line with three semi-colons (;;;) the line will be treated as a comment and will not be executed. 

Note: Three semi-colons will tab-adjust the comment two positions to the right.

Examples:
This example prints the numbers from 1 to 5. The print("hello") expression will never execute since it is a comment.

for x from 1 to 5 do
			;;; print("hello")
	print(x)
end for 
#end

#begin
variable
Syntax:
variable

Comment:
A variable is a named reference to an object. To make a variable reference an object you have to assign the variable to the object.
The expression
a := 12
will assign the variable a to the integer object 12.
When a variable is evaluated in CraftScript-code it will evaluate to the object it is assigned to.
So in this example the variable a will evaluate to the integer object 12.

Examples:
a
b
hello
v1212
'a variable'
#end

#begin
:=
Syntax:
variable := expr

Comment:
A variable is a named reference to an object. To make a variable reference an object you have to assign the variable to the object.
The expression
a := 12
will assign the variable a to the integer object 12.
When a variable is evaluated in CraftScript-code it will evaluate to the object it is assigned to.
So in this example the variable a will evaluate to the integer object 12.

Examples:
a := 12
b := "a string"
hello := #a_symbol
v1212 := {window}:new
'a variable' := 12 + 23 / (45 + 9)
#end

#begin
local_variable
Syntax:
local variable

Comment:
A local variable is a variable that only exists locally within CraftScript methods. 
If you type in a method 
x := 50
one of two things will happen:

1. If the object has a property named x that property will be assigned to the integer object 50.
2. If the object does not have a property named x the local variable x will be assigned to the integer object 50.

If you want to assign the local variable x even if there is a property x you type
local x := 50

Examples:
local a := 50
x := 50 + local a
#end

#begin
global_variable
Syntax:
global variable

Comment:
A global variable is a variable that can be accessed by all CraftScript methods. 

If you type
global x := 50
the global variable x will be assigned to the integer object 50.
If another script includes something like
a := 20 + global x
then the variable a will be assigned to 70 (i.e. the sum of 20 and 50).

Global variables is a way to exchange data between objects.

All global variables in your program can be inspected in the program appearance inspector. 

Note: When you assign variables in the Console window they will be global for your convenience.

Examples:
global a := 50
x := 50 + global a
#end

#begin
property_variable
Syntax:
property prop_name

Comment:
You may use a local variable in a method that has the same name as a property of the object. To be able to differ between the local variable and the property you may use the property keyword.

Assume that x is both a local variable and a property. The expression
a := x
will assign the variable a to the value of the local variable x.
If you want to assign the variable a to the property x you have to type
a := property x

Examples:
property a := 50
b := 20 + property a
#end

#begin
object.prop_name
Syntax:
object.prop

Comment:
If you want to access a property of an object there is usually a method for that. For example if you want to get the x coordinate of a button you type
{button my_button}:x

You can also get the value of a property by using a dot notation:
{button my_button}.x

A property may be public. A public property may be accessed by the dot notation.
A public property may be read only. A read only property may only be read by the dot notation. You cannot set the value of a read only property with the dot notation.

Note: You set the public and read only flags in the class properties inspector.

Examples:
x_coord := {button my_button}.x
my_obj.my_prop := "a string"
#end

#begin
object.prop_name_assignment
Syntax:
object.prop := expr

Comment:
If you want to set a property of an object there is usually a method for that. For example if you want to set the tag of a button you type
{button my_button}:set_tag(#my_tag)

You can also set the value of a property by using a dot notation:
{button my_button}.tag := #my_tag

A property may be public. A public property may be accessed by the dot notation.
A public property may be read only. A read only property may only be read by the dot notation. You cannot set the value of a read only property with the dot notation.

Note: You set the public and read only flags in the class properties inspector.

Examples:
my_obj.my_prop := "a string"
#end

#begin
protect
Syntax:
protect 
	exprs_1
with 
	exprs_2
end protect 

Comment:
The protect statement is used to protect CraftScript code from opening the Exception Panel, i.e. a run-time error. 
If an exception is raised by the system while executing an expression in exprs_1, the expressions in exprs_2 will be executed instead of opening the Exception Panel.
When the expressions in exprs_2 starts to execute, the global variable the_error will contain the error-code for the exception. 
For instance, if you try to divide something by 0, an exception will be raised and the global variable the_error will contain the error-code #divide_by_zero.

Examples:
Define a method for the program that returns 100 divided by x:

define method divide_100_by(x)
	of the_program
	as 
	protect 
		return 100 / x
	with 
		print(the_error)
	end protect 
	return self
end define

the_program:divide_100_by(2)
returns 50

the_program:divide_100_by(0)
raises an exception and the global variable the_error is printed in the console.
#divide_by_zero

Also see raise, reraise and the_error
#end

#begin
raise
Syntax:
raise expr 

Comment:
The raise statement raises an exception and puts expr into the global variable the_error.

Examples:
Define a method for the program that returns 10 divided by x:

define method divide_10_by(x)
	of the_program
	as 
	protect 
		if x = 0 then 
			raise #my_own_divide_by_zero
		end if 
		return 10 / x
	with 
		print(the_error)
	end protect 
	return self
end define 

the_program:divide_100_by(2)
returns 5

the_program:divide_100_by(0)
raises your own exception and the global variable the_error is printed in the console.
#my_own_divide_by_zero

Also see protect, reraise and the_error
#end

#begin
reraise
Syntax:
reraise

Comment:
The reraise statement can be used in a protect statement to reraises the exception for the calling method to handle it.

Examples:
Define a method for the program that returns 100 divided by x:

define method divide_100_by(x)
	of the_program
	as 
	protect 
		return 100 / x
	with 
		print(the_error)
		reraise 
	end protect 
	return self
end define 

the_program:divide_100_by(2)
returns 50

the_program:divide_100_by(0)
raises an exception and the global variable the_error is printed in the console. 
#divide_by_zero
The exception is then raised again for the calling method to handle.
In this case the Exception Panel will appear.

Also see protect, raise and the_error
#end

#begin
the_error
Syntax:
the_error

Comment:
the_error is a constant. The value of the constant the_error is set by the system when an exception is raised or by the raise statement.

Examples:
Define a method for the program that returns 100 divided by x:

define method divide_100_by(x)
	of the_program
	as 
	protect 
		return 100 / x
	with 
		print(the_error)
		reraise 
	end protect 
	return self
end define 

the_program:divide_100_by(2)
returns 50

the_program:divide_100_by(0)
raises an exception and the global variable the_error is printed in the console. 
#divide_by_zero

Also see protect, raise and reraise
#end

#begin
for_from_to
Syntax:
for var from expr_1 to expr_2 do
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2 by 1. 
Returns the value of the last evaluated expression in exprs.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and each time print the value of x in the console.

for x from 1 to 10 do
	print("------")
	print(x)
	print("------")
end for 
#end

#begin
for_from_downto
Syntax:
for var from expr_1 downto expr_2 do
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 down to the value of expr_2 by -1. 
Returns the value of the last evaluated expression in exprs.

Note: The expression expr_1 must be higher than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 10 down to 1, i.e. ten times and each time print the value of x in the console.

for x from 10 downto 1 do
	print("------")
	print(x)
	print("------")
end for 
#end

#begin
for_from_as
Syntax:
for var_1 from expr_1 to expr_2 as 
	var_2 from expr_3 to expr_3 do
	exprs
end for 

Comment:
Makes the variable var_1 loop from the value of expr_1 to the value of expr_2 by 1 and the variable var_2 loop from the value of expr_3 to the value of expr_4 by 1. The loop will stop when one of the variables reaches its top value. 
Returns the value of the last evaluated expression in exprs.

Note: The expression expr_1 must be higher than the expression expr_2 etc. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 5 and the variable y loop from 2 to 8, i.e. five times and each time print the value of x + y in the console. The loop stops when the variable x reaches the value 5.

for x from 1 to 5 as
	y from 2 to 8 do
	print("------")
	print(x + y)
	print("------")
end for 
#end

#begin
for_from_by
Syntax:
for var from expr_1 to expr_2 by expr_3 do	
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2 by the value of expr_3. 
Returns the value of the last evaluated expression in exprs.

Note: The expression expr_1 must be lower than the expression expr_2 and the value of the expression expr_3 must be larger than 0. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 2 to 10 by 2, i.e. five times and each time print the value of x in the console.

for x from 2 to 10 by 2 do
	print("------")
	print(x)
	print("------")
end for 
#end

#begin
for_from_when
Syntax:
for var from expr_1 to expr_2 when expr_3 do	
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. The expressions in exprs will only be evaluated if the expression expr_3 evaluates to true. 
Returns the value of the last evaluated expression in exprs.

Note: The expression expr_1 must be lower than the expression expr_2 and the value of the expression expr_3 must be larger than 0. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and print the value of x in the console only if x is odd.

for x from 1 to 10 when x:is_odd do
	print("------")
	print(x)
	print("------")
end for 
#end

#begin
for_from_collect
Syntax:
for var from expr_1 to expr_2 collect
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns a collection where each item is the value of the last evaluated expression in exprs for each iteration.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return the collection of all the values of x, i.e. [1 2 3 4 5 6 7 8 9 10].

for x from 1 to 10 collect
	x
end for 
#end

#begin
for_from_sum
Syntax:
for var from expr_1 to expr_2 sum
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns the sum of the value of the last evaluated expression in exprs for each iteration.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return the sum of all the values of x, i.e. 55.

for x from 1 to 10 sum
	x
end for 
#end

#begin
for_from_largest
Syntax:
for var from expr_1 to expr_2 largest
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns the largest value of the last evaluated expression in exprs for each iteration.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return the largest of all the values of x, i.e. 10.

for x from 1 to 10 largest
	x
end for 
#end

#begin
for_from_smallest
Syntax:
for var from expr_1 to expr_2 smallest
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns the smallest value of the last evaluated expression in exprs for each iteration.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return the smallest of all the values of x, i.e. 1.

for x from 1 to 10 smallest
	x
end for 
#end

#begin
for_from_thereis
Syntax:
for var from expr_1 to expr_2 thereis
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns true if the value of the last evaluated expression in exprs is true for one or more iterations. Otherwise it returns false.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return true because exprs will evaluate to true one time.

for x from 1 to 10 thereis
	x = 4
end for 
#end

#begin
for_from_always
Syntax:
for var from expr_1 to expr_2 always
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns true if the value of the last evaluated expression in exprs is true for all iterations. Otherwise it returns false.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return false because exprs will evaluate to false one time.

for x from 1 to 10 always
	x < 10
end for 
#end

#begin
for_from_never
Syntax:
for var from expr_1 to expr_2 never
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns true if the value of the last evaluated expression in exprs is false for all iterations. Otherwise it returns false.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return true because exprs will evaluate to false all the time.

for x from 1 to 10 never
	x > 100
end for 
#end

#begin
for_from_count
Syntax:
for var from expr_1 to expr_2 count
	exprs
end for 

Comment:
Makes the variable var loop from the value of expr_1 to the value of expr_2. 
Returns the number of times the value of the last evaluated expression in exprs is true.

Note: The expression expr_1 must be lower than the expression expr_2. Otherwise the loop will not run and return nil.

Examples:
This example will make the variable x loop from 1 to 10, i.e. ten times and return the number of times x is odd, i.e. 5.

for x from 1 to 10 count
	x:is_odd
end for 
#end

#begin
for_in
Syntax:
for var in expr do
	exprs
end for 

Comment:
Makes the variable var loop over the elements of expr. The value of expr must be a collection or a string. 
Returns the value of the last evaluated expression in exprs.

Examples:
This example will make the variable x loop over the list my_list and print the value of x in the console.

my_list := [1 2 3 4 5]
for x in my_list do
	print("------")
	print(x)
	print("------")
end for 

Note: In for...in loops you can use all the different constructs used in for...from loops like by, as, when, collect, sum, largest, smallest, thereis, always, never and count. 
Examples:
for x in [1 2 3] always
	x < 10
end for

for x in [1 2 3] as
	y in [2 3 4] do 
	print(x + y)
end for

for x in [1 2 3] when x < 3 do
	print(x)
end for
#end

#begin
:
Syntax:
object:message

Comment:
Sends the message to an object. Returns the return value of object's implementation of message.
If object does not understand message or if the number of arguments are wrong an exception will be raised.

Examples:
12:as_string
returns "12"

[1 2 3 4]:size
returns 4

{window}:new
returns a new window object

{menu main}:add_cell({menu_cell}:new)
adds a new menu cell to the main menu.
Returns the new cell.
#end

#begin
:!
Syntax:
object:!message 

Comment:
Sends the message to an object if the object is not nil. Returns the return value of object's implementation of message.
If object does not understand message or if the number of arguments are wrong an exception will be raised.

Examples:
nil:!move(10, 20)
returns nil
(Note that 
nil:move(10, 20) 
will raise an exception.)

12:!as_string
returns "12"

[1 2 3 4]:!size
returns 4

{window}:!new
returns a new window object

{menu main}:!add_cell({menu_cell}:!new)
adds a new menu cell to the main menu.
Returns the new cell.
#end

#begin
:?
Syntax:
object:?message 

Comment:
Sends the message to an object only if the object understands the message. Returns the return value of object's implementation of message.
If the number of arguments are wrong an exception will be raised.

Examples:
{window}:?move(10, 20)
returns nil
(Note that 
{window}:move(10, 20) 
will raise an exception.)

12:!?as_string
returns "12"

[1 2 3 4]:?size
returns 4

{window}:?new
returns a new window object

{menu main}:?add_cell({menu_cell}:?new)
adds a new menu cell to the main menu.
Returns the new cell.
#end

#begin
super
Syntax:
super:message 

Comment:
Passes message to the next object in the inheritance hierarchy.

Note: You should only send super:foo from within the method foo, i.e. to pass it on in the inheritance hierarchy.

Examples:
In the do_action method of a button you might be interested in executing the default do_action also.
This do_action method of a button will first print "I was clicked!", then execute the do_action of the control class. (I.e. send the action message to the target object).

define method do_action
	of {button 8}
	in events 
	as 
	print("I was clicked!")
	return super:do_action
end define 
#end

#begin
+
Syntax:
expr_1 + expr_2 

Comment:
Returns the sum of expr_1 and expr_2.

Note: This expression is actually translated to 
expr_1:add(expr_2)
If you implement the add(x) method for your own class you can add objects of your own class with the '+'-operator.

Examples:
12 + 23
returns 35

12.3 + 23.1
returns 35.400000

"hello " + "world"
returns "hello world"
#end

#begin
-
Syntax:
expr_1 - expr_2 

Comment:
Returns the difference of expr_1 and expr_2.

Note: This expression is actually translated to 
expr_1:subtract(expr_2)
If you implement the subtract(x) method for your own class you can subtract objects of your own class with the '-'-operator.

Examples:
12 - 7
returns 5

12.3 - 7.6
returns 4.700000
#end

#begin
*
Syntax:
expr_1 * expr_2 

Comment:
Returns the product of expr_1 and expr_2.

Note: This expression is actually translated to 
expr_1:times(expr_2)
If you implement the times(x) method for your own class you can multiply objects of your own class with the '*'-operator.

Examples:
3 * 4
returns 12

12.3 * 7.6
returns 93.480000
#end

#begin
/
Syntax:
expr_1 / expr_2 

Comment:
Returns the result of dividing expr_1 by expr_2.

Note: This expression is actually translated to 
expr_1:divide(expr_2)
If you implement the divide(x) method for your own class you can divide objects of your own class with the '/'-operator.

Examples:
100 / 20
returns 5

12.3 / 7.6
returns 1.618421
#end

#begin
//
Syntax:
expr_1 // expr_2 

Comment:
Returns the result of dividing expr_1 by expr_2 and rounding it down to the nearest lower integer.

Note: This expression is actually translated to 
expr_1:divide_and_truncate(expr_2)
If you implement the divide_and_truncate(x) method for your own class you can divide and truncate objects of your own class with the '//'-operator.

Examples:
100 // 20
returns 5

5 // 2
returns 2
#end

#begin
%
Syntax:
expr_1 % expr_2 

Comment:
Returns the reminder when expr_1 is divide_and_truncated with expr_2.

Note: This expression is actually translated to 
expr_1:reminder(expr_2)
If you implement the reminder(x) method for your own class you can perform this operation on objects of your own class with the '%'-operator.

Examples:
100 % 20
returns 0

5 % 2
returns 1
#end

#begin
^
Syntax:
expr_1 ^ expr_2 

Comment:
Returns the result of expr_1 raised to expr_2.

Note: This expression is actually translated to 
expr_1:raised_to(expr_2)
If you implement the raised_to(x) method for your own class you can perform this operation on objects of your own class with the '^'-operator.

Examples:
5 ^ 2
returns 25

10 ^ 5
returns 100000

2 ^ 63
returns 9223372036854775807

Note: This is the largest integer CraftMan can handle.
#end

#begin
()
Syntax:
(exprs)

Comment:
Parenthesis are used to group expressions to control the order of execution.

Examples:
5 * 2 + 3
returns 13

5 * (2 + 3)
returns 25
#end

#begin
=
Syntax:
expr_1 = expr_2 

Comment:
Returns true if expr_1 is equal to expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
expr_1:is_equal_to(expr_2)
If you implement the is_equal_to(x) method for your own class you can compare objects of your own class with the '='-operator.

Examples:
5 = 2
returns false

6 = 5 + 1
returns true

"hello" = "hello"
returns true
#end

#begin
==
Syntax:
expr_1 == expr_2 

Comment:
Returns true if expr_1 evaluates to the same object as expr_2. Otherwise it returns false.

Examples:
5 == 5
returns true

"hello" == "hello"
returns false

a := "hello"
b := "hello"
c := a

a == b
returns false

a == c
returns true
#end

#begin
<>
Syntax:
expr_1 <> expr_2 

Comment:
Returns true if expr_1 is not equal to expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
not expr_1:is_equal_to(expr_2)
If you implement the is_equal_to(x) method for your own class you can compare objects of your own class with the '<>'-operator.

Examples:
5 <> 2
returns true

6 <> 5 + 1
returns false

"hello" <> "hello"
returns false
#end

#begin
<!>
Syntax:
expr_1 <!> expr_2 

Comment:
Returns true if expr_1 does not evaluate to the same object as expr_2. Otherwise it returns false.

Examples:
5 <!> 5
returns false

"hello" <!> "hello"
returns true

a := "hello"
b := "hello"
c := a

a <!> b
returns true

a <!> c
returns false
#end

#begin
>
Syntax:
expr_1 > expr_2 

Comment:
Returns true if expr_1 is greater than expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
expr_1:is_greater_than(expr_2)
If you implement the is_greater_than(x) method for your own class you can compare objects of your own class with the '>'-operator.

Examples:
5 > 2
returns true

6 > 5 + 1
returns false

"bcd" > "abc"
returns true
#end

#begin
<
Syntax:
expr_1 < expr_2 

Comment:
Returns true if expr_1 is less than expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
expr_1:is_less_than(expr_2)
If you implement the is_less_than(x) method for your own class you can compare objects of your own class with the '<'-operator.

Examples:
5 < 2
returns false

3 < 5 + 1
returns true

"abc" < "bcd"
returns true
#end

#begin
>=
Syntax:
expr_1 >= expr_2 

Comment:
Returns true if expr_1 is greater than or equal to expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
expr_1:is_greater_than_or_equal(expr_2)
If you implement the is_greater_than_or_equal(x) method for your own class you can compare objects of your own class with the '>='-operator.

Examples:
5 >= 2
returns true

6 >= 5 + 1
returns true

"abc" >= "bcd"
returns false
#end

#begin
<=
Syntax:
expr_1 <= expr_2 

Comment:
Returns true if expr_1 is less than or equal to expr_2. Otherwise it returns false.

Note: This expression is actually translated to 
expr_1:is_less_than_or_equal(expr_2)
If you implement the is_less_than_or_equal(x) method for your own class you can compare objects of your own class with the '<='-operator.

Examples:
5 <= 2
returns false

6 <= 5 + 1
returns true

"abc" <= "bcd"
returns true
#end

#begin
and
Syntax:
expr_1 and expr_2 

Comment:
Returns true if expr_1 and expr_2 are both true. Otherwise it returns false.

Examples:
true and false
returns false

false and false
returns false

true and true
returns true

1 < 4 and 4 > 5
returns false
#end

#begin
or
Syntax:
expr_1 or expr_2 

Comment:
Returns true if at least one of expr_1 and expr_2 is true. Otherwise it returns false.

Examples:
true or false
returns true

false or false
returns false

true or true
returns true

1 < 4 or 4 > 5
returns true
#end

#begin
not
Syntax:
not expr 

Comment:
Returns false if expr evaluates to true. Otherwise it returns true.

Examples:
not true
returns false

not false
returns true

not (1 < 4 or 4 > 5)
returns true
#end

#begin
true
Syntax:
true 

Comment:
true is a constant. The value of the constant true is always true.
#end

#begin
false
Syntax:
false 

Comment:
false is a constant. The value of the constant false is always false.
#end

#begin
nil
Syntax:
nil 

Comment:
nil is a constant. The value of the constant nil is always nil.
#end

#begin
the_program
Syntax:
the_program 

Comment:
the_program is a constant. The value of the constant the_program is always the current program object.

Examples:
the_program:date
returns the current date

the_program:quit
closes the current program
#end

#begin
pi
Syntax:
pi 

Comment:
pi is a constant. The value of the constant pi is always 3.141593.

Examples:
12 + pi
returns 15.141593
#end

#begin
the_craftman
Syntax:
the_craftman 

Comment:
the_craftman is a constant. The value of the constant the_craftman is always the CraftMan Application object.

Examples:
the_craftman:hide
hides the CraftMan application in the Workspace.

the_craftman:user_name 
Returns a string containing the name of the user.
#end

#begin
string
Syntax:
"a string" 

Comment:
A string is written as a double quote (") followed by a number of characters followed by another double quote (").

Use backslash (\) to protect quotes in a string.

If you want to assign the variable s the string:
She said: "Hello!"
you type
"She said: \"Hello!\""

Examples:
"An example of a string!"
#end

#begin
symbol
Syntax:
#symbol 

Comment:
A symbol is written as a hash mark (#) followed by a number of characters.

Examples:
#a
#a_symbol
#a_very_long_symbol
#end

#begin
escaped_symbol
Syntax:
#'an escaped symbol' 

Comment:
An escaped symbol a symbol that includes white space. It is written as a hash mark (#) followed by a number of characters. The characters are surrounded by '.

Examples:
#'a a'
#'a symbol'
#'a very long symbol'
#end

#begin
area
Syntax:
{x y width height} 

Comment:
An area represents a rectangular area with the origin at (x, y) and with the size (width, height).

Examples:
{0 0 100 100}
#end

#begin
point
Syntax:
{x y} 

Comment:
A point represents a point at (x, y).

Examples:
{50 80}
#end

#begin
collection
Syntax:
[element_1 element_2 element_3 ...element_n]

Comment:
A collection is an ordered list of objects. It is written as a left square bracket ([) followed by the objects delimited by a space followed by a right square bracket (]).

Examples:
[1 2 3 4 5]
["a" "collection" "of" "strings"]

Note 1: A collection may include objects of different classes:
[1 2 3 the_program {button} [5 6 7]]

Note 2: A collection may include itself:
a := [1 2 3 4 5]
a:add_last(a)
returns [1 2 3 4 5 ...]
(The ellipsis (...) represents the collection itself).
#end

#begin
integer
Examples:
12
5
12353454764
#end

#begin
float
Examples:
12.3
5.0000
13213.1231
#end

#begin
character
Syntax:
\a

Comment:
A character is typed as a backslash (\) followed by the character.

Examples:
\A is the character A.
\b is the character b.

"hello orld":insert(\w, 7)
returns "hello world"

Note: There are a number of special characters:

\space	(the space character)
\cr	(the carriage return character)
\nl	(the new line character)
\tab	(the tab character)
#end

#begin
space
Syntax:
\space

Comment:
\space is the special character space.

Examples:
"helloworld":insert(\space, 6)
returns "hello world"
#end

#begin
tab
Syntax:
\tab

Comment:
\tab is the special character tab.
#end

#begin
cr
Syntax:
\cr

Comment:
\cr is the special character carriage return.
#end

#begin
nl
Syntax:
\nl

Comment:
\nl is the special character new line.

Examples:
"helloworld":insert(\nl, 6)
returns 
"hello
world"
#end